Welcome to the World of Pokemon

library(datasets)

First lets bring in the Pokemon dataset.

Pokemon = read.csv(file = 'data/Pokemon.csv')
head(Pokemon)
##   X.                  Name Type.1 Type.2 Total HP Attack Defense Sp..Atk
## 1  1             Bulbasaur  Grass Poison   318 45     49      49      65
## 2  2               Ivysaur  Grass Poison   405 60     62      63      80
## 3  3              Venusaur  Grass Poison   525 80     82      83     100
## 4  3 VenusaurMega Venusaur  Grass Poison   625 80    100     123     122
## 5  4            Charmander   Fire          309 39     52      43      60
## 6  5            Charmeleon   Fire          405 58     64      58      80
##   Sp..Def Speed Generation Legendary
## 1      65    45          1     False
## 2      80    60          1     False
## 3     100    80          1     False
## 4     120    80          1     False
## 5      50    65          1     False
## 6      65    80          1     False



Reasearch Question 1:

What is the most common type for pokemon?

Since there are secondary typing for Pokemon, we will have to combine the observations from the two variables.


But first lets see what the data shows for Pokemon that only have one type.

# this is the Type.2 for charmander
# a Pokemon that has a singular "Fire" type

Pokemon$Type.2[5]
## [1] ""

The data displays a “” or empty for a Pokemon that has to Type.2. This will muddy our data if we’re looking for the most common type, since technically “” is a valid observation as far as the code is concerned.


These are the tables for Type.1 and Type.2 variables.

table(Pokemon$Type.1)
## 
##      Bug     Dark   Dragon Electric    Fairy Fighting     Fire   Flying 
##       69       31       32       44       17       27       52        4 
##    Ghost    Grass   Ground      Ice   Normal   Poison  Psychic     Rock 
##       32       70       32       24       98       28       57       44 
##    Steel    Water 
##       27      112
table(Pokemon$Type.2)
## 
##               Bug     Dark   Dragon Electric    Fairy Fighting     Fire 
##      386        3       20       18        6       23       26       12 
##   Flying    Ghost    Grass   Ground      Ice   Normal   Poison  Psychic 
##       97       14       25       35       14        4       34       33 
##     Rock    Steel    Water 
##       14       22       14
# how many types are in Type.1
length(table(Pokemon$Type.1)) 
## [1] 18
# how many types are in Type.2
length(table(Pokemon$Type.2))
## [1] 19

As you can see there is an extra type in table(Pokemon$Type.2) that is “” with the number 386 to represent all of the observations/Pokemon with “” for Type.2.


This is the combined table of Type.1 and Type.2, minus the empty “” type Now we need to be careful, because this does not represent every Pokemon. As you can see when we look at the sum of the table, it shows 1214 when we only have 800 observations/Pokemon.

combinedTypeTable = (table(Pokemon$Type.1) + table(Pokemon$Type.2)[-1])


paste("The sum is: ", sum(combinedTypeTable))
## [1] "The sum is:  1214"

Finally lets see which type is the most common for pokemon, either as their Type.1 OR their Type.2.

# finds the max(table), and then finds the index of the max value, then returns both the number and its name, in our case the type

combinedTypeTable[which(combinedTypeTable == max(combinedTypeTable))]
## Water 
##   126

As you can see, the most common typing for a Pokemon is Water.

But as always a visualization will help in contextualizing this piece of information.

combinedTypeTable = sort(combinedTypeTable, decreasing=TRUE)
barplot(combinedTypeTable[1:5], main = "TOP 5 MOST COMMON TYPES IN POKEMON", ylab="Frequency", col=c("lightblue"))



Reasearch Question 2: *ADD A “Total” Option to the Final Graph that Shows Total Amount of that Type

What generation has the greatest number of each “type”(Type.1 and Type.2 combined) of Pokemon


First we need to know how many different generations are present in our data.

table(Pokemon$Generation)
## 
##   1   2   3   4   5   6 
## 166 106 160 121 165  82

There are 6 different generations of Pokemon listed in the data, with a varying number of Pokemon for each generation.

Now we need to parse the data so that we can see how many of each type is in each generation.

# table for the number of each Type.1 type for all entries where the Generation is 1
table(Pokemon$Type.1[which(Pokemon$Generation == 1)])
## 
##      Bug   Dragon Electric    Fairy Fighting     Fire    Ghost    Grass 
##       14        3        9        2        7       14        4       13 
##   Ground      Ice   Normal   Poison  Psychic     Rock    Water 
##        8        2       24       14       11       10       31
# table for the number of each Type.2 type for all entries where the Generation is 1
table(Pokemon$Type.2[which(Pokemon$Generation == 1)])
## 
##              Dark   Dragon    Fairy Fighting   Flying    Grass   Ground 
##       88        1        1        3        2       23        2        6 
##      Ice   Poison  Psychic     Rock    Steel    Water 
##        3       22        7        2        2        4
length(table(Pokemon$Type.1[which(Pokemon$Generation == 1)]))
## [1] 15
length(table(Pokemon$Type.2[which(Pokemon$Generation == 1)]))
## [1] 14

But we run in to a problem due to the way that Pokemon types are set up. A Pokemon has one or two types, and the Type.2 is valued the same as Type.1. This means that we need to count both when looking at how many types of each Pokemon are in each generation. For example the first Pokemon in the data, Bulbasaur, would count as both a “Grass” and “Poison” type, with both holding equal weight. This causes discrepancies like we see above, where some types are missing from the Type.2 table and the Type.1 table . We will have to modify the table ourselves to make this work.


Since we will most likely have to do this for every generation, lets make a function that fills in the missing “types” and returns one vector with the combined values for both Type.1 and Type.2

# this function will help us combine the two Type tables int o one table with all unique types from both Type.1 and Type.2, as well as add up duplicates


combineTypeTblByGen = function(generation){
  
  # merging the table of Type.1 and Type.2 for the generation
  mergedTypeTable = merge(table(Pokemon$Type.1[which(Pokemon$Generation == generation)]), table(Pokemon$Type.2[which(Pokemon$Generation == generation)])[-1], all= TRUE)
  
  
  # vector version of the merged tables above
  typeVec = mergedTypeTable[[2]]
  names(typeVec) = mergedTypeTable[[1]]
  
  
  
  # for loop that adds up the repeat values for the types, and then removes the duplicate name+value from the vector
  len = length(typeVec) - 1
  for(i in 1:len){
  
    if(i >= length(typeVec)){break}
  
    else if(names(typeVec[i]) == names(typeVec[i + 1])){

      typeVec[i+1] = typeVec[i] + typeVec[i+1]
      #print(typeVec[i])

      typeVec = typeVec[-c(i)]
  
    }

  }
  
  return(typeVec)
  
  
}


barplot(combineTypeTblByGen(1), las=2, main="Frequency of Types for Generation 1")

The plot above combines frequency of “types” in both Type1 and Type2 for generation 1, and because we have the function combineTypeTblByGen() we are able to replicate this for every other generation as well.


Since we have the combined tables for every generation, we can move on to comparing the generations by Type.

This next function will allow us to see how many of one specific type is in every generation. For example it will allow us to see the number of “Bug” types there are in generation 1 through 6.

# function takes in a character argument that represents a Pokemon Type and returns a vector of length 6, with each index representing the number of that type of pokemon are in that generation number

compareTypeAcrossGen = function(type){
  
  oneTypeAllGensVec = c()
  
  for(i in 1:6){
    
    #print(combineTypeTblByGen(i)[type])
    
    oneTypeAllGensVec[i] = combineTypeTblByGen(i)[type]
   
    
  }

  names(oneTypeAllGensVec) = c("Gen 1", "Gen 2", "Gen 3", "Gen 4", "Gen 5", "Gen 6")
  
  return(oneTypeAllGensVec)

}


compareTypeAcrossGen("Bug")
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    14    12    14    11    18     3
compareTypeAcrossGen("Dark")
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##     1     8    13     7    16     3
barplot(compareTypeAcrossGen("Bug"), main="Frequency of Bug Types in Each Generation(Gen)", las=2, col = "lightgreen")

We have the comparisons across generations for individual types, but that doesn’t accomplish anything unless we want to create 18 different barplots. Instead lets use the plotly package to create an interactive barplot that shows the frequency of each type across the generations to get a broader understanding of the dataset.

typeByGenTraces[]
## [[1]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    14    12    14    11    18     3 
## 
## [[2]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##     4     2    15     4    12     9 
## 
## [[3]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##     9     9     5    12    12     3 
## 
## [[4]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##     5     8     8     1     3    14 
## 
## [[5]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##     9     2     9    10    17     4 
## 
## [[6]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    14    11     9     6    16     8 
## 
## [[7]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##     4     1     8     9     9    15 
## 
## [[8]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    15    10    18    17    20    15 
## 
## [[9]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    14    11    16    12    12     2 
## 
## [[10]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##     5     5     7     8     9     2 
## 
## [[11]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    24    15    18    18    19     4 
## 
## [[12]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    36     4     5     8     7     2 
## 
## [[13]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    18    10    28    10    16     8 
## 
## [[14]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    12     8    12     7    10     9 
## 
## [[15]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    35    18    31    15    18     9 
## 
## [[16]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##     1     8    13     7    16     3 
## 
## [[17]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##    23    19    14    16    21     8 
## 
## [[18]]
## Gen 1 Gen 2 Gen 3 Gen 4 Gen 5 Gen 6 
##     2     3    12    12    12     5
q2FinalGraph

Lets do some Querying

library(DBI)
library(RSQLite)
## Warning: package 'RSQLite' was built under R version 4.4.3
drv = dbDriver("SQLite")

pokemonDatabase = dbConnect(drv, dbname = "./data/veekun-pokedex.sqlite")
dbExecute(pokemonDatabase, "PRAGMA foreign_keys = on")
## [1] 0
dbListTables(pokemonDatabase)
##   [1] "abilities"                          "ability_changelog"                 
##   [3] "ability_changelog_prose"            "ability_flavor_text"               
##   [5] "ability_names"                      "ability_prose"                     
##   [7] "berries"                            "berry_firmness"                    
##   [9] "berry_firmness_names"               "berry_flavors"                     
##  [11] "characteristic_text"                "characteristics"                   
##  [13] "conquest_episode_names"             "conquest_episode_warriors"         
##  [15] "conquest_episodes"                  "conquest_kingdom_names"            
##  [17] "conquest_kingdoms"                  "conquest_max_links"                
##  [19] "conquest_move_data"                 "conquest_move_displacement_prose"  
##  [21] "conquest_move_displacements"        "conquest_move_effect_prose"        
##  [23] "conquest_move_effects"              "conquest_move_range_prose"         
##  [25] "conquest_move_ranges"               "conquest_pokemon_abilities"        
##  [27] "conquest_pokemon_evolution"         "conquest_pokemon_moves"            
##  [29] "conquest_pokemon_stats"             "conquest_stat_names"               
##  [31] "conquest_stats"                     "conquest_transformation_pokemon"   
##  [33] "conquest_transformation_warriors"   "conquest_warrior_archetypes"       
##  [35] "conquest_warrior_names"             "conquest_warrior_rank_stat_map"    
##  [37] "conquest_warrior_ranks"             "conquest_warrior_skill_names"      
##  [39] "conquest_warrior_skills"            "conquest_warrior_specialties"      
##  [41] "conquest_warrior_stat_names"        "conquest_warrior_stats"            
##  [43] "conquest_warrior_transformation"    "conquest_warriors"                 
##  [45] "contest_combos"                     "contest_effect_prose"              
##  [47] "contest_effects"                    "contest_type_names"                
##  [49] "contest_types"                      "egg_group_prose"                   
##  [51] "egg_groups"                         "encounter_condition_prose"         
##  [53] "encounter_condition_value_map"      "encounter_condition_value_prose"   
##  [55] "encounter_condition_values"         "encounter_conditions"              
##  [57] "encounter_method_prose"             "encounter_methods"                 
##  [59] "encounter_slots"                    "encounters"                        
##  [61] "evolution_chains"                   "evolution_trigger_prose"           
##  [63] "evolution_triggers"                 "experience"                        
##  [65] "genders"                            "generation_names"                  
##  [67] "generations"                        "growth_rate_prose"                 
##  [69] "growth_rates"                       "item_categories"                   
##  [71] "item_category_prose"                "item_flag_map"                     
##  [73] "item_flag_prose"                    "item_flags"                        
##  [75] "item_flavor_summaries"              "item_flavor_text"                  
##  [77] "item_fling_effect_prose"            "item_fling_effects"                
##  [79] "item_game_indices"                  "item_names"                        
##  [81] "item_pocket_names"                  "item_pockets"                      
##  [83] "item_prose"                         "items"                             
##  [85] "language_names"                     "languages"                         
##  [87] "location_area_encounter_rates"      "location_area_prose"               
##  [89] "location_areas"                     "location_game_indices"             
##  [91] "location_names"                     "locations"                         
##  [93] "machines"                           "move_battle_style_prose"           
##  [95] "move_battle_styles"                 "move_changelog"                    
##  [97] "move_damage_class_prose"            "move_damage_classes"               
##  [99] "move_effect_changelog"              "move_effect_changelog_prose"       
## [101] "move_effect_prose"                  "move_effects"                      
## [103] "move_flag_map"                      "move_flag_prose"                   
## [105] "move_flags"                         "move_flavor_summaries"             
## [107] "move_flavor_text"                   "move_meta"                         
## [109] "move_meta_ailment_names"            "move_meta_ailments"                
## [111] "move_meta_categories"               "move_meta_category_prose"          
## [113] "move_meta_stat_changes"             "move_names"                        
## [115] "move_target_prose"                  "move_targets"                      
## [117] "moves"                              "nature_battle_style_preferences"   
## [119] "nature_names"                       "nature_pokeathlon_stats"           
## [121] "natures"                            "pal_park"                          
## [123] "pal_park_area_names"                "pal_park_areas"                    
## [125] "pokeathlon_stat_names"              "pokeathlon_stats"                  
## [127] "pokedex_prose"                      "pokedex_version_groups"            
## [129] "pokedexes"                          "pokemon"                           
## [131] "pokemon_abilities"                  "pokemon_color_names"               
## [133] "pokemon_colors"                     "pokemon_dex_numbers"               
## [135] "pokemon_egg_groups"                 "pokemon_evolution"                 
## [137] "pokemon_form_generations"           "pokemon_form_names"                
## [139] "pokemon_form_pokeathlon_stats"      "pokemon_forms"                     
## [141] "pokemon_game_indices"               "pokemon_habitat_names"             
## [143] "pokemon_habitats"                   "pokemon_items"                     
## [145] "pokemon_move_method_prose"          "pokemon_move_methods"              
## [147] "pokemon_moves"                      "pokemon_shape_prose"               
## [149] "pokemon_shapes"                     "pokemon_species"                   
## [151] "pokemon_species_flavor_summaries"   "pokemon_species_flavor_text"       
## [153] "pokemon_species_names"              "pokemon_species_prose"             
## [155] "pokemon_stats"                      "pokemon_types"                     
## [157] "region_names"                       "regions"                           
## [159] "stat_names"                         "stats"                             
## [161] "super_contest_combos"               "super_contest_effect_prose"        
## [163] "super_contest_effects"              "type_efficacy"                     
## [165] "type_game_indices"                  "type_names"                        
## [167] "types"                              "version_group_pokemon_move_methods"
## [169] "version_group_regions"              "version_groups"                    
## [171] "version_names"                      "versions"

This database and tables needs to be “cleaned” or organized into the information that I actually need –> practice organizing and putting data togehter with joins
Questions to ask/analyze:
how has the stats fro certain types changed over the course of the generartions?
is this change significant?

Goal 1: Create a table/df with all relevant info like pokemon speciest, pokedex number, stats, moves, pokedex flavor text, habitat, strengths and weaknesses, enocunters, locations, abilities

Goal 2:

Pokedex app? image, stats, and reads pokedex entry? check normality for stats by type hypothesis: flying types are significantly faster than ground, check?

dbListFields(pokemonDatabase, "pokemon_species_flavor_text")
## [1] "species_id"  "version_id"  "language_id" "flavor_text"
dbGetQuery(pokemonDatabase, "
           SELECT *
           FROM pokemon_species_flavor_text
           LIMIT 100")
##     species_id version_id language_id
## 1            1          1           9
## 2            1          2           9
## 3            1          3           9
## 4            1          4           9
## 5            1          5           9
## 6            1          6           9
## 7            1          7           9
## 8            1          8           9
## 9            1          9           9
## 10           1         10           9
## 11           1         11           9
## 12           1         12           9
## 13           1         13           9
## 14           1         14           9
## 15           1         15           9
## 16           1         16           9
## 17           1         17           5
## 18           1         17           9
## 19           1         18           5
## 20           1         18           9
## 21           1         21           9
## 22           1         22           9
## 23           1         23           1
## 24           1         23           3
## 25           1         23           5
## 26           1         23           6
## 27           1         23           7
## 28           1         23           8
## 29           1         23           9
## 30           1         23          11
## 31           1         24           1
## 32           1         24           3
## 33           1         24           5
## 34           1         24           6
## 35           1         24           7
## 36           1         24           8
## 37           1         24           9
## 38           1         24          11
## 39           1         25           1
## 40           1         25           3
## 41           1         25           5
## 42           1         25           6
## 43           1         25           7
## 44           1         25           8
## 45           1         25           9
## 46           1         25          11
## 47           1         26           1
## 48           1         26           3
## 49           1         26           5
## 50           1         26           6
## 51           1         26           7
## 52           1         26           8
## 53           1         26           9
## 54           1         26          11
## 55           2          1           9
## 56           2          2           9
## 57           2          3           9
## 58           2          4           9
## 59           2          5           9
## 60           2          6           9
## 61           2          7           9
## 62           2          8           9
## 63           2          9           9
## 64           2         10           9
## 65           2         11           9
## 66           2         12           9
## 67           2         13           9
## 68           2         14           9
## 69           2         15           9
## 70           2         16           9
## 71           2         17           5
## 72           2         17           9
## 73           2         18           5
## 74           2         18           9
## 75           2         21           9
## 76           2         22           9
## 77           2         23           1
## 78           2         23           3
## 79           2         23           5
## 80           2         23           6
## 81           2         23           7
## 82           2         23           8
## 83           2         23           9
## 84           2         23          11
## 85           2         24           1
## 86           2         24           3
## 87           2         24           5
## 88           2         24           6
## 89           2         24           7
## 90           2         24           8
## 91           2         24           9
## 92           2         24          11
## 93           2         25           1
## 94           2         25           3
## 95           2         25           5
## 96           2         25           6
## 97           2         25           7
## 98           2         25           8
## 99           2         25           9
## 100          2         25          11
##                                                                                                                                                                                                                                  flavor_text
## 1                                                                                                                                       A strange seed was\nplanted on its\nback at birth.\fThe plant sprouts\nand grows with\nthis POKéMON.
## 2                                                                                                                                       A strange seed was\nplanted on its\nback at birth.\fThe plant sprouts\nand grows with\nthis POKéMON.
## 3                                                                                                                                         It can go for days\nwithout eating a\nsingle morsel.\fIn the bulb on\nits back, it\nstores energy.
## 4                                                                                                                                      The seed on its\nback is filled\nwith nutrients.\fThe seed grows\nsteadily larger as\nits body grows.
## 5                                                                                                                                        It carries a seed\non its back right\nfrom birth. As it\fgrows older, the\nseed also grows\nlarger.
## 6                                                                                                                                   While it is young,\nit uses the\nnutrients that are\fstored in the\nseeds on its back\nin order to grow.
## 7                                                                                      BULBASAUR can be seen napping in\nbright sunlight.\nThere is a seed on its back.\fBy soaking up the sun’s rays, the seed\ngrows progressively larger.
## 8                                                                                      BULBASAUR can be seen napping in\nbright sunlight.\nThere is a seed on its back.\fBy soaking up the sun’s rays, the seed\ngrows progressively larger.
## 9                                                                                       BULBASAUR can be seen napping in bright\nsunlight. There is a seed on its back.\nBy soaking up the sun’s rays, the seed\ngrows progressively larger.
## 10                                                                                                                                There is a plant seed on its back right\nfrom the day this POKéMON is born.\nThe seed slowly grows larger.
## 11                                                                                                                                         A strange seed was planted on its back at\nbirth. The plant sprouts and grows with\nthis POKéMON.
## 12                                                                                                                                               For some time after its birth, it\ngrows by gaining nourishment from\nthe seed on its back.
## 13                                                                                                                                               For some time after its birth, it\ngrows by gaining nourishment from\nthe seed on its back.
## 14                                                                                                                                               For some time after its birth, it\ngrows by gaining nourishment from\nthe seed on its back.
## 15                                                                                                                                        The seed on its back is filled\nwith nutrients. The seed grows\nsteadily larger as its body grows.
## 16                                                                                                                                          It carries a seed on its back right\nfrom birth. As it grows older, the\nseed also grows larger.
## 17                                                                                                                                       Au matin de sa vie, la graine sur\nson dos lui fournit les éléments\ndont il a besoin pour grandir.
## 18                                                                                                                                               For some time after its birth, it\ngrows by gaining nourishment from\nthe seed on its back.
## 19                                                                                                                                       Au matin de sa vie, la graine sur\nson dos lui fournit les éléments\ndont il a besoin pour grandir.
## 20                                                                                                                                               For some time after its birth, it\ngrows by gaining nourishment from\nthe seed on its back.
## 21                                                                                                                                               For some time after its birth, it\ngrows by gaining nourishment from\nthe seed on its back.
## 22                                                                                                                                               For some time after its birth, it\ngrows by gaining nourishment from\nthe seed on its back.
## 23                                                                                                                                              うまれたときから せなかに\nふしぎな タネが うえてあって\nからだと ともに そだつという。
## 24                                                                                                                                                               태어났을 때부터 등에\n이상한 씨앗이 심어져 있으며\n몸과 함께 자란다고 한다.
## 25                                                                                                                                                  Il a une étrange graine plantée sur son dos.\nElle grandit avec lui depuis sa naissance.
## 26                                                                                                                                             Dieses Pokémon trägt von Geburt an einen Samen\nauf dem Rücken, der mit ihm keimt und wächst.
## 27                                                                                                                                          Una rara semilla le fue plantada en el lomo al nacer.\nLa planta brota y crece con este Pokémon.
## 28                                                                                                                                        Alla nascita gli è stato piantato sulla schiena un seme\nraro. La pianta sboccia e cresce con lui.
## 29                                                                                                                                          A strange seed was planted on its back at birth.\nThe plant sprouts and grows with this Pokémon.
## 30                                                                                                                                                      生まれたときから 背中に\n不思議な タネが 植えてあって\n体と ともに 育つという。
## 31                                                                                                                                          うまれてから しばらくの あいだは\nせなかの タネから えいようを\nもらって おおきく そだつ。
## 32                                                                                                                                                               태어나서부터 얼마 동안은\n등의 씨앗으로부터 영양을\n공급받아 크게 성장한다.
## 33                                                                                                                                        Au matin de sa vie, la graine sur son dos lui fournit\nles éléments dont il a besoin pour grandir.
## 34                                                                                                                                                 Nach der Geburt nimmt es für eine Weile Nährstoffe\nüber den Samen auf seinem Rücken auf.
## 35                                                                                                                                                                        Después de nacer, crece alimentándose de las\nsemillas de su lomo.
## 36                                                                                                                                                              Dopo la nascita, cresce traendo nutrimento dal seme\npiantato sul suo dorso.
## 37                                                                                                                                                For some time after its birth, it grows by gaining\nnourishment from the seed on its back.
## 38                                                                                                                                                    生まれてから しばらくの あいだは\n背中の タネから 栄養を もらって\n大きく 育つ。
## 39                                                                                                     ひなたで ひるねを する すがたを  かける。\nたいようの ひかりを いっぱい あびることで\nせなかの タネが おおきく そだつのだ。
## 40                                                                                                                                                  양지에서 낮잠 자는 모습을 볼 수 있다.\n태양의 빛을 많이 받으면\n등의 씨앗이 크게 자란다.
## 41                                                                     Bulbizarre passe son temps à faire la sieste sous le soleil.\nIl y a une graine sur son dos. Il absorbe les rayons du soleil\npour faire doucement pousser la graine.
## 42                                                                   Bisasam macht gern einmal ein Nickerchen im\nSonnenschein. Auf seinem Rücken trägt es einen\nSamen. Indem es Sonnenstrahlen aufsaugt,\nwird der Samen zunehmend größer.
## 43                                                                               A Bulbasaur es fácil verle echándose una siesta al sol.\nLa semilla que tiene en el lomo va creciendo cada vez más\na medida que absorbe los rayos del sol.
## 44                                                       È possibile vedere Bulbasaur mentre schiaccia un pisolino\nsotto il sole. Ha un seme piantato sulla schiena. Grazie ai\nraggi solari il seme cresce ingrandendosi progressivamente.
## 45                                                                                       Bulbasaur can be seen napping in bright sunlight.\nThere is a seed on its back. By soaking up the sun’s rays,\nthe seed grows progressively larger.
## 46                                                                                                                        日なたで 昼寝を する 姿を 見かける。\n太陽の 光を いっぱい 浴びることで\n背中の タネが 大きく 育つのだ。
## 47                                                                                                     ひなたで ひるねを する すがたを  かける。\nたいようの ひかりを いっぱい あびることで\nせなかの タネが おおきく そだつのだ。
## 48                                                                                                                                                  양지에서 낮잠 자는 모습을 볼 수 있다.\n태양의 빛을 많이 받으면\n등의 씨앗이 크게 자란다.
## 49                                                                     Bulbizarre passe son temps à faire la sieste sous le soleil.\nIl y a une graine sur son dos. Il absorbe les rayons du soleil\npour faire doucement pousser la graine.
## 50                                                                          Bisasam macht gern einmal ein Nickerchen im\nSonnenschein. Auf seinem Rücken trägt es einen\nSamen. Indem es Sonnenstrahlen aufsaugt,\nwird er zunehmend größer.
## 51                                                                               A Bulbasaur es fácil verle echándose una siesta al sol.\nLa semilla que tiene en el lomo va creciendo cada vez más\na medida que absorbe los rayos del sol.
## 52                                                       È possibile vedere Bulbasaur mentre schiaccia un pisolino\nsotto il sole. Ha un seme piantato sulla schiena. Grazie ai\nraggi solari il seme cresce ingrandendosi progressivamente.
## 53                                                                                       Bulbasaur can be seen napping in bright sunlight.\nThere is a seed on its back. By soaking up the sun’s rays,\nthe seed grows progressively larger.
## 54                                                                                                                        日なたで 昼寝を する 姿を 見かける。\n太陽の 光を いっぱい 浴びることで\n背中の タネが 大きく 育つのだ。
## 55                                                                                                                                     When the bulb on\nits back grows\nlarge, it appears\fto lose the\nability to stand\non its hind legs.
## 56                                                                                                                                     When the bulb on\nits back grows\nlarge, it appears\fto lose the\nability to stand\non its hind legs.
## 57                                                                                                                                       The bulb on its\nback grows by\ndrawing energy.\fIt gives off an\naroma when it is\nready to bloom.
## 58                                                                                                                                    Exposure to sun­\nlight adds to its\nstrength. Sunlight\falso makes the bud\non its back grow\nlarger.
## 59                                                                                                                                  If the bud on its\nback starts to\nsmell sweet, it\fis evidence that\nthe large flower\nwill soon bloom.
## 60                                                                                                                              The bulb on its\nback grows as it\nabsorbs nutrients.\fThe bulb gives off\na pleasant aroma\nwhen it blooms.
## 61   There is a bud on this POKéMON’s back.\nTo support its weight, IVYSAUR’s legs\nand trunk grow thick and strong.\fIf it starts spending more time lying\nin the sunlight, it’s a sign that the\nbud will bloom into a large flower soon.
## 62   There is a bud on this POKéMON’s back.\nTo support its weight, IVYSAUR’s legs\nand trunk grow thick and strong.\fIf it starts spending more time lying\nin the sunlight, it’s a sign that the\nbud will bloom into a large flower soon.
## 63                                                                                            To support its bulb, IVYSAUR’s legs\ngrow sturdy. If it spends more time lying in\nthe sunlight, the bud will soon bloom into\na large flower.
## 64                                                                                                                          There is a plant bulb on its back.\nWhen it absorbs nutrients, the bulb is said\nto blossom into a large flower.
## 65                                                                                                                                        When the bulb on its back grows large, it\nappears to lose the ability to stand on\nits hind legs.
## 66                                                                                                                                    When the bud on its back starts\nswelling, a sweet aroma wafts to\nindicate the flower’s coming bloom.
## 67                                                                                                                                    When the bud on its back starts\nswelling, a sweet aroma wafts to\nindicate the flower’s coming bloom.
## 68                                                                                                                                    When the bud on its back starts\nswelling, a sweet aroma wafts to\nindicate the flower’s coming bloom.
## 69                                                                                                                                         Exposure to sunlight adds to its\nstrength. Sunlight also makes the\nbud on its back grow larger.
## 70                                                                                                                                     If the bud on its back starts to\nsmell sweet, it is evidence that\nthe large flower will soon bloom.
## 71                                                                                                                                             Lorsque le bourgeon sur son dos\néclot, il répand un doux parfum\npour célébrer sa floraison.
## 72                                                                                                                                    When the bud on its back starts\nswelling, a sweet aroma wafts to\nindicate the flower’s coming bloom.
## 73                                                                                                                                             Lorsque le bourgeon sur son dos\néclot, il répand un doux parfum\npour célébrer sa floraison.
## 74                                                                                                                                    When the bud on its back starts\nswelling, a sweet aroma wafts to\nindicate the flower’s coming bloom.
## 75                                                                                                                                    When the bud on its back starts\nswelling, a sweet aroma wafts to\nindicate the flower’s coming bloom.
## 76                                                                                                                                    When the bud on its back starts\nswelling, a sweet aroma wafts to\nindicate the flower’s coming bloom.
## 77                                                                                                                                        つぼみが せなかに ついていて\nようぶんを きゅうしゅうしていくと\nおおきな はなが さくという。
## 78                                                                                                                                                                  꽃봉오리가 등에 붙어 있으며\n양분을 흡수해가면\n커다란 꽃이 핀다고 한다.
## 79                                                                                                                    Il y a un bulbe sur son dos. On dit que s’il absorbe\nassez de nutriments, ce bulbe se transforme en\nune jolie fleur.
## 80                                                                                                                 Es trägt eine Knospe auf seinem Rücken. Nimmt es\nNahrung zu sich, soll aus der Knospe eine große\nblühende Blume werden.
## 81                                                                                                                   Este Pokémon tiene un bulbo en el lomo. Dicen que,\nal absorber nutrientes, el bulbo se transforma en una\nflor grande.
## 82                                                                                                                                Dopo aver assorbito sufficienti sostanze nutrienti,\nil bulbo sulla schiena sboccia in un magnifico fiore.
## 83                                                                                                                          There is a plant bulb on its back.\nWhen it absorbs nutrients, the bulb is said to\nblossom into a large flower.
## 84                                                                                                                                                          つぼみが 背中に ついていて\n養分を 吸収していくと\n大きな 花が 咲くという。
## 85                                                                                                                            せなかの つぼみが ふくらみだすと\nあまい においが ただよいはじめる。\nたいりんの はなが さく まえぶれ。
## 86                                                                                                                                                         등의 봉오리가 부풀어 오르면\n달콤한 냄새가 감돌기 시작한다.\n큰 꽃이 필 조짐이다.
## 87                                                                                                                                              Lorsque le bourgeon sur son dos éclot, il répand\nun doux parfum pour célébrer sa floraison.
## 88                                                                                                                                                  Sobald die Knospe auf seinem Rücken ein süßes\nAroma abgibt, steht die Blüte kurz bevor.
## 89                                                                                                                                            Cuando el bulbo de su lomo se hincha, desprende un\ndulce aroma para indicar el florecimiento.
## 90                                                                                                                                Quando il bocciolo che ha sul dorso si gonfia, emana\nun dolce profumo. È indice dell’imminente fioritura.
## 91                                                                                                                                     When the bud on its back starts swelling, a sweet\naroma wafts to indicate the flower’s coming bloom.
## 92                                                                                                                                            背中の つぼみが ふくらみ出すと\n甘い においが 漂いはじめる。\n大輪の 花が 咲く 前触れ。
## 93                                                                                                 つぼ を ささえるため あしこしが つよくなる。\nひなたで じっとする じかんが ながくなれば\nいよいよ たいりんの はなが さくころだ。
## 94                                                                                                                            꽃봉오리를 지탱하기 위해 하반신이 강해진다.\n양지에서 가만히 있는 시간이 길어지면\n드디어 커다란 꽃이 필 때다.
## 95  Un bourgeon a poussé sur le dos de ce Pokémon. Pour en\nsupporter le poids, Herbizarre a dû se muscler les pattes.\nLorsqu’il commence à se prélasser au soleil, ça signifie que\nson bourgeon va éclore, donnant naissance à une fleur.
## 96                                 Bisaknosp hat eine Knospe auf seinem Rücken.\nBeine und Rumpf sind kräftig genug, um sein Gewicht\nzu tragen. Wenn es lange in der Sonne liegt, ist das\nein Anzeichen dafür, dass die Knospe bald blüht.
## 97                  Este Pokémon lleva un bulbo en el lomo y, para poder con\nsu peso, tiene unas patas y un tronco gruesos y fuertes.\nSi empieza a pasar más tiempo al sol, será porque el bulbo\nestá a punto de hacerse una flor grande.
## 98   C’è un germoglio piantato nella schiena di Ivysaur.\nPer sopportarne il peso, le zampe e il corpo crescono robusti.\nQuando inizia a passare più tempo esposto al sole, significa\nche il germoglio sboccerà presto in un grande fiore.
## 99     There is a bud on this Pokémon’s back. To support its weight,\nIvysaur’s legs and trunk grow thick and strong.\nIf it starts spending more time lying in the sunlight,\nit’s a sign that the bud will bloom into a large flower soon.
## 100                                                                                                                  つぼ を 支えるため 足腰が 強くなる。\n日なたで じっとする 時間が 長くなれば\nいよいよ 大輪の 花が 咲くころだ。
dbListFields(pokemonDatabase, "pokemon_stats")
## [1] "pokemon_id" "stat_id"    "base_stat"  "effort"
dbGetQuery(pokemonDatabase, "
           SELECT *
           FROM  pokemon_stats
           LIMIT 20")
##    pokemon_id stat_id base_stat effort
## 1           1       1        45      0
## 2           1       2        49      0
## 3           1       3        49      0
## 4           1       4        65      1
## 5           1       5        65      0
## 6           1       6        45      0
## 7           2       1        60      0
## 8           2       2        62      0
## 9           2       3        63      0
## 10          2       4        80      1
## 11          2       5        80      1
## 12          2       6        60      0
## 13          3       1        80      0
## 14          3       2        82      0
## 15          3       3        83      0
## 16          3       4       100      2
## 17          3       5       100      1
## 18          3       6        80      0
## 19          4       1        39      0
## 20          4       2        52      0
dbGetQuery(pokemonDatabase, 
           "PRAGMA FOREIGN_KEY_LIST(pokemon_stats)")
##   id seq   table       from to on_update on_delete match
## 1  0   0   stats    stat_id id NO ACTION NO ACTION  NONE
## 2  1   0 pokemon pokemon_id id NO ACTION NO ACTION  NONE
dbListFields(pokemonDatabase, "pokemon_species_names")
## [1] "pokemon_species_id" "local_language_id"  "name"              
## [4] "genus"
dbGetQuery(pokemonDatabase, "
           SELECT *
           FROM  pokemon_species_names
           LIMIT 20")
##    pokemon_species_id local_language_id        name   genus
## 1                   1                 1  フシギダネ    たね
## 2                   1                 2 Fushigidane    <NA>
## 3                   1                 3    이상해씨    씨앗
## 4                   1                 4    妙蛙種子    <NA>
## 5                   1                 5  Bulbizarre  Graine
## 6                   1                 6     Bisasam   Samen
## 7                   1                 7   Bulbasaur Semilla
## 8                   1                 8   Bulbasaur    Seme
## 9                   1                 9   Bulbasaur    Seed
## 10                  2                 1  フシギソウ    たね
## 11                  2                 2  Fushigisou    <NA>
## 12                  2                 3    이상해풀    씨앗
## 13                  2                 4      妙蛙草    <NA>
## 14                  2                 5  Herbizarre  Graine
## 15                  2                 6   Bisaknosp   Samen
## 16                  2                 7     Ivysaur Semilla
## 17                  2                 8     Ivysaur    Seme
## 18                  2                 9     Ivysaur    Seed
## 19                  3                 1  フシギバナ    たね
## 20                  3                 2 Fushigibana    <NA>
dbGetQuery(pokemonDatabase, 
           "PRAGMA FOREIGN_KEY_LIST(pokemon_species_names)")
##   id seq           table               from to on_update on_delete match
## 1  0   0       languages  local_language_id id NO ACTION NO ACTION  NONE
## 2  1   0 pokemon_species pokemon_species_id id NO ACTION NO ACTION  NONE

Research Question 3: How does each individual stat vary across the different types.

When I think of flying type Pokemon, I imagine fast aerial predators, so naturally you would think that their speed stat is significantly higher than that of ground/rock types that are usually large boulders and giants. But do the stats, get it?, actually back this up? Lets Find Out!

For Flying vs Ground: T test to compare samples of the speed stat taken from the flying and ground types.
Make this modular so it can be used for any combination of types and stats.

This can then be replicated for each stat for each type. For example you may want to see if the Fire type, chock full of aggressive Pokemon like Houndoom, have a significantly higher attack stat than a gentler pokemon type such as grass.

Step 1
Do some querying so we have a useful dataframe to work with.

dbDisconnect(pokemonDatabase)